<template>
	<div>
		<!--头部-->
		<header>
			<div class="header_body">

				<div class="po_img">
					<a href="#"><img src="../static/images/logo_03.jpg" class="logo" style="width: 204px;height: 152px;border-radius: 15px;"></a>
				</div>

				<div class="header_enter">
					<ul v-if='loginState'>
						<li @click="tuichu">
							<a href="javascrip:void(0)">
								退出登录
							</a>
						</li>
					</ul>
					<ul v-else>
						<li>
							<router-link to="login">
								登录&nbsp;&nbsp;|&nbsp;&nbsp;
							</router-link>
						</li>
						<li>
							<router-link to="register">
								注册
							</router-link>
						</li>
					</ul>

				</div>

				<div class="header_p">
					<p>你好欢迎您来到顺芝堂网站！</p>
				</div>
				<!--右侧菜单-->
				<div class="nav">
					<ul>
						<li class="nava">
							<router-link to="/">首页</router-link>
						</li>
						<li class="nava">
							<router-link to="shopCar">
								购物车
							</router-link>
						</li>
						<li class="nava">
							<router-link to="order">
								商品订单
							</router-link>
						</li>
						<li class="nava">
							<router-link to="about">
								关于我们
							</router-link>
						</li>
						<li class="clo">
							<a href="javascript:;"><img src="../static/images/o_03.png">个人中心</a>
							<ul class="drop-down-content" id="luing">
								<router-link to="myAccount">
									<li>
										<a href="javascript:void(0)">
											我的账户
										</a>
									</li>
								</router-link>
								<router-link to="partner">
									<li>
										<a href="javascript:void(0)">
											合作伙伴
										</a>
									</li>
								</router-link>
								<router-link to="info">
									<li>
										<a href="javascript:void(0)">
											信息管理
										</a>
									</li>
								</router-link>
							</ul>
						</li>
					</ul>
				</div>

			</div>
			<div class="zero"></div>
		</header>

	</div>
</template>
<script>
	export default {
		created() {
			var self = this
			this.$api.get('/front/base/isLogin', null, r => {
				console.log('登录接口r', r)
				if(r.code === 200) {
					self.loginState = true
				} else {
					self.loginState = false
					self.$router.replace({
						path: '/login'
					})
				}
			})
		},
		data() {
			return {
				loginState: false
			}
		},
		methods: {
			tuichu: function() {
				var self = this
				this.$api.get('/front/base/logout', null, r => {
					console.log('退出r', r)
					if(r.code === 200) {
						self.$router.replace({
							path: '/login'
						})
						self.$message({
							type: 'success',
							message: r.data
						})
					} else {
						self.$message({
							type: 'success',
							message: r.error
						})
					}

				})
			}

		},
		updated() {}

	}
</script>